﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UPTrace;

namespace TowerDefence_Zombie
{
    /// <summary>
    /// 游戏入口。
    /// </summary>
    public partial class GameEntry : MonoBehaviour
    {
        float entryTime;
        private void Start()
        {
            entryTime = Time.realtimeSinceStartup;
            InitBuiltinComponents();
            InitCustomComponents();
        }

        private void OnApplicationPause(bool pause)
        {
            int status;
            if (pause)
            {
                status = 1;
                //程序进入后台时执行
                UPTraceApi.resignActive();
            }
            else
            {
                status = 0;
                //程序从后台进入前台时
                UPTraceApi.becomeActive();
                UPTraceApi.traceKey("T01");
            }
            float duration = Time.realtimeSinceStartup - entryTime;
            Dictionary<string, string> dic = new()
            {
                { "U", UPTraceApi.getUserId() },
                { "status", status.ToString() },
                { "T", duration.ToString() },
                { "curr", DateTime.Now.ToString() },
            };
            Debug.Log($"UPTraceApi traceDictionary TA02 {dic["curr"]}");
            UPTraceApi.traceDictionary("TA02", dic);

        }
    }
}
